/*
 * simple_createtion_thread.cpp
 *
 *  Created on: Feb 9, 2009
 *      Author: tandaica0612
 */
 /*
 g++ -o simple_createtion_thread simple_createtion_thread.cpp `pkg-config --libs gthread-2.0` `pkg-config glibmm-2.4 --cflags --libs`
 */
#include <iostream>
#include <glibmm/thread.h>
using namespace std;
void thread_function(){
	for(int i = 0;i<10;i++){
		cout << "Sub thread :" << i << endl;
		sleep(1);
	}
}
using namespace std;
int main(){
	if(!Glib::thread_supported()){
		Glib::thread_init();
	}
	Glib::Thread *thread = Glib::Thread::create(sigc::ptr_fun(&thread_function),true);//"true" cho phep' join thread
	for(int i = 0;i<5;i++){
		cout << "Main thread :" << i << endl;
		sleep(1);
	}
	thread->join();//wait thread terminal rui` exit
	return 0;
}
